<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <script>
    // 方式1
    window.onresize = function () {};
    // 方式2
    window.addEventListener('resize', function () {});
  </script>
</body>
</html>